package com.only4play.productcenter.api.constans;

import com.only4play.common.constants.BaseEnum;

import java.util.Optional;

public enum DirectionType implements BaseEnum<DirectionType> {

  IN(1, "入"),
  OUT(2,"出"),
  ;

  DirectionType(Integer code, String name) {
    this.code = code;
    this.name = name;
  }

  private Integer code;
  private String name;

  @Override
  public Integer getCode() {
    return this.code;
  }

  @Override
  public String getName() {
    return this.name;
  }

  public static Optional<DirectionType> of(Integer code) {
    return Optional.ofNullable(BaseEnum.parseByCode(DirectionType.class, code));
  }

}
